#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<stdbool.h>
#include<assert.h>
#include<iostream>
#include<vector>
#include<list>
using namespace std;
//int main()
//{
//	vector<int> a;
//	a.push_back(1);
//	a.push_back(2);
//	a.push_back(3);
//	a.push_back(4);
//	a.push_back(5);
//	vector<int>::iterator begin = a.begin();
//	vector<int>::iterator end = a.end();
//	cout << *begin << endl;
//	return 0;
//}
void TestVectorExpand()
{
	size_t sz;
	vector<int> v;
	v.reserve(100);
	sz = v.capacity();
	cout << "making v grow:\n";
	for (int i = 0; i < 100; ++i)
	{
		v.push_back(i);
		if (sz != v.capacity())
		{
			sz = v.capacity();
			cout << "capacity changed: " << sz << '\n';
		}
	}
}
void test_vector3()
{
	//TestVectorExpand();

	vector<int> v;
	for (size_t i = 0; i < 100; i++)
	{
		v.push_back(i);
	}

	cout << v.size() << endl;
	cout << v.capacity() << endl;

	v.resize(10);
	cout << v.size() << endl;
	cout << v.capacity() << endl;

	v.shrink_to_fit();

	cout << v.size() << endl;
	cout << v.capacity() << endl;
}
void test_vector4()
{
	vector<int> v;
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	for (auto e : v)
	{
		cout << e << " ";
	}
	cout << endl;

	v.insert(v.begin(), 0);

	for (auto e : v)
	{
		cout << e << " ";
	}
	cout << endl;

	//vector<int>::iterator it = find(v.begin(), v.end(), 3);
	auto it = find(v.begin(), v.end(), 3);

	v.insert(it, 30);

	for (auto e : v)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int> lt;
	lt.push_back(10);
	lt.push_back(20);
	lt.push_back(30);
	lt.push_back(40);
	auto lit = find(lt.begin(), lt.end(), 3);

	if (lit != lt.end())
	{
		lt.insert(lit, 300);
	}

	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	vector<string> vstr;
	string s1("");
	vstr.push_back(s1);
	vstr.push_back(string(""));

	vstr.push_back("");

	for (const auto& e : vstr)
	{
		cout << e << " ";
	}
	cout << endl;

	cout << vstr[0][0] << 'z' << endl;
	cout << vstr[0][3] << endl;
}
void test4()
{
	vector<int> s;
	s.reserve(100);
	s.push_back(1);
	s.push_back(2);
	s.push_back(3);
	s.push_back(4);
	s.push_back(5);
	s.push_back(6);
	s.push_back(7);
	for (auto a : s)
	{
		cout << a << " ";
	}
	cout << endl;
	vector<int>::iterator it = s.begin();
	s.insert(it+3,10);
	for (auto a : s)
	{
		cout << a << " ";
	}
	cout << endl;
	s.erase(it + 4,it+5);
	for (auto a : s)
	{
		cout << a << " ";
	}
	cout << endl;

}
int main()
{
	//TestVectorExpand();
	//test_vector3();
	//test_vector4();
	test4();
	return 0;
}